<template>
	<view class="mainpadding2">
		<!-- 已选中 -->
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class=" margin_top" v-for="item in list.data" :key="item.id" @click="selectrole(item)">
			<view class="flexleft yxzbox" v-if="item.status==10">
				<view class="nerbox youbk">
					<view class="smalltext xiaobai nofonweight">￥
						<text class="bigtext xiaobai fonweight">{{item.price}}</text>
					</view>
					<view class="strongtext xiaobai nofonweight margin_top1">
						{{Number(item.mj_price)==0?"无使用门槛":"满"+item.mj_price}}
					</view>
				</view>
				<view class="nerbox">
					<view class="sanshier xiaobai nofonweight">{{item.name}}</view>
					<view class="strongtext xiaobai nofonweight margin_top1">有效截止日期：{{item.end_time_text}}</view>
				</view>
			</view>
			<!-- 已使用 -->
			<view class="wexbxo" v-if="item.status==20">
				<view class="flexleft ">
					<view class="nerbox youbk">
						<view class="smalltext xiaolv nofonweight">￥
							<text class="bigtext xiaolv fonweight">{{item.price}}</text>
						</view>
						<view class="strongtext xiaohei nofonweight margin_top1">
							{{Number(item.mj_price)==0?"无使用门槛":"满"+item.mj_price}}
						</view>
					</view>
					<view class="nerbox">
						<view class="sanshier xiaohei nofonweight">{{item.name}}</view>
						<view class="strongtext xiaohei nofonweight margin_top1">有效截止日期：{{item.end_time_text}}</view>
					</view>
				</view>
				<view class="mainpadding">
					<view class="ershiba xiaohui nofonweight ">已使用</view>
				</view>
			</view>
			<!-- 已过期 -->
			<view class="wexbxo toumd" v-if="item.status==30">
				<view class="flexleft xiahuaxian1">
					<view class="nerbox youbk">
						<view class="smalltext xiaolv nofonweight">￥
							<text class="bigtext xiaolv fonweight">{{item.price}}</text>
						</view>
						<view class="strongtext xiaohei nofonweight margin_top1">
							{{Number(item.mj_price)==0?"无使用门槛":"满"+item.mj_price}}
						</view>
					</view>
					<view class="nerbox">
						<view class="sanshier xiaohei nofonweight">{{item.name}}</view>
						<view class="strongtext xiaohei nofonweight margin_top1">有效截止日期：{{item.end_time_text}}</view>
					</view>
				</view>
				<view class="mainpadding">
					<view class="ershiba xiaohui nofonweight ">优惠券已过期</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				type: 0,
			}
		},
		onLoad(options) {
			if (options.type) {
				this.type = options.type
			}
			this.init()
		},
		methods: {
			selectrole(item) {
				if (this.type == 1 && item.status == 10) {
					uni.$emit("checkyhq", item)
					uni.navigateBack(1)
				}
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit
				}
				let url = '/api/user/userCoupon'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.toumd {
		opacity: 0.5;
	}

	.xiahuaxian1 {
		border-bottom: 1rpx solid #F5F5F5;
	}

	.nerbox {
		padding: 38rpx 31rpx;
	}

	.wexbxo {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.youbk {
		border-right: 2rpx solid #F5F5F5;
	}

	.yxzbox {
		background: #1BA95B;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	page {
		background: #F9F9F9;
	}
</style>